package bento.views.pnls;

import javax.swing.JPanel;
import javax.swing.JTabbedPane;

import bento.IHasWrapper;
import bento.IWrapper;
import bento.api.IBentoClient;
import bento.views.pnls.PnlMain.Wrapper;

import java.awt.BorderLayout;
import java.awt.Component;

public class PnlMain extends JPanel implements IHasWrapper<PnlMain.Wrapper> {
    private Wrapper wrapper;
    
    private PnlGate pnlGate;
    private PnlOrders pnlOrders;
    private PnlStores pnlStores;
    private PnlManager pnlManager;
    private JTabbedPane tabbedPane;
    
    @Override
    public Wrapper getWrapper() {
        return wrapper;
    }

    /**
     * Create the panel.
     */
    public PnlMain() {
        setLayout(new BorderLayout(0, 0));
        
        tabbedPane = new JTabbedPane(JTabbedPane.TOP);
        add(tabbedPane);
        
        pnlGate = new PnlGate();
        tabbedPane.addTab("Gate", null, pnlGate, null);
        tabbedPane.setEnabledAt(0, false);
        
        pnlOrders = new PnlOrders();
        tabbedPane.addTab("Order", null, pnlOrders, null);
        tabbedPane.setEnabledAt(1, false);
        
        pnlStores = new PnlStores();
        tabbedPane.addTab("Store", null, pnlStores, null);
        
        pnlManager = new PnlManager();
        tabbedPane.addTab("Manager", null, pnlManager, null);
        tabbedPane.setEnabledAt(3, false);

    }

    public class Wrapper implements IWrapper<Component> {
        private PnlGate   .Wrapper gate;
        private PnlOrders .Wrapper orders;
        private PnlStores .Wrapper stores;
        private PnlManager.Wrapper manager;
        
        public PnlGate.Wrapper getGate() {
            return gate;
        }

        public PnlOrders.Wrapper getOrders() {
            return orders;
        }

        public PnlStores.Wrapper getStores() {
            return stores;
        }

        public PnlManager.Wrapper getManager() {
            return manager;
        }

        @Override
        public Component get() {
            return PnlMain.this;
        }
        
        public Wrapper(IBentoClient bentoClient) {
            PnlMain.this.wrapper= this;
            gate   = pnlGate.new Wrapper(bentoClient);
            orders = pnlOrders.new Wrapper(bentoClient);
            stores = pnlStores.new Wrapper(bentoClient);
            manager= pnlManager.new Wrapper(bentoClient);
            tabbedPane.setSelectedComponent(stores.get());
        }
    }


}
